#include <stdio.h>
#include <stdlib.h>

int main() {
    int m, i, c, count;
    scanf("%d", &m);
    int *arr = (int *)malloc(m * sizeof(int)); 
    scanf("%d", &count);
    for (i = 0; i < m; i++) {
        scanf("%d", &c);
        arr[i] = c;
    }
    for (i = 0; i < count; i++) {
        int start, end, score;
        scanf("%d", &start);
        scanf("%d", &end);
        scanf("%d", &score);
        for (int j = start - 1; j <= end - 1; j++)
            arr[j] = arr[j] + score;
    }
    int min = arr[0];

   
    for (i = 0; i < m; i++) {
        if (arr[i] < min)
            min = arr[i];
    }

    printf("%d", min);

    free(arr);
    return 0;
}
